<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
if (!function_exists('small')) {
    /**
     * 渲染输出Small
     * @param string    $name Small名称
     * @param array     $data 传入的参数
     * @return mixed
     */
    function small($name, $data = [])
    {
        static $small;
        static $unique_id;
        $unique_id++;
        $data['unique_id'] = $unique_id;
        $arrName = explode('/', $name);
        if( isset($small[$name]) )
        {
            return $small[$name]->$arrName[1]($data);
        }
        else
        {
            include Env::get('module_path') . 'small' . DIRECTORY_SEPARATOR . 'controller' . DIRECTORY_SEPARATOR . $arrName[0] .'.php';
            $className = '\\app\\'. \think\facade\Request::module() .'\\small\\' . $arrName[0];
            $small[$name] = new $className();
            return $small[$name]->$arrName[1]($data);
        }
    }
}

